#!/bin/bash

if [ $# -eq 0 ]; then
    ifconfig |grep inet |awk '{print $1,$2}' |sed 's/%/ /'|sort
elif [ "x$1" == "x4" ]; then
    ifconfig |grep 'inet ' |awk '{print $1,$2}' 
elif [ "x$1" == "x6" ]; then
    ifconfig |grep 'inet6 ' |awk '{print $1,$2}' |sed 's/%/ /' |sort
elif [ "x$1" == "xpub" ]; then
    curl http://ip.cn
fi
